<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>Insert title here</title>
<style type="text/css">
	
	html,body{
		width:100%;
		height:100%;
		padding:0;
		margin:0;
	}
	
	body{
		display: flex;
		flex-direction: column;
		align-items: center;/*交叉轴对齐方式*/
		justify-content: center;/*主轴对齐方式*/
	}
	
	.login-form{
		box-sizing:border-box;
		width:700px;				
		padding-bottom:30px;
		font-size:14px;
		background-color:#FCFCFC;
		border:1px solid #DDDDDD;
		border-radius:10px;
		box-shadow:0px 0px 10px 2px #DDDDDD;
		position:relative;		
	}
	
	.login-form h1{
		text-align: center;
		font-family:楷体;
		font-size:60px;
		font-weight:bold;
		color:#002288;
		margin:30px 0 20px 0;
	}
	
	.login-form div{
		margin: 0 auto 22px;
		text-align:center;
	}
	
	.login-form label{
		display:inline-block;
		width:60px;		
		font-weight:bold;
	}
	
	.login-form input[type=text],.login-form input[type=password]{
		width:260px;
		height:40px;
		border:1px solid #DDDDDD;
		border-radius:5px;
		padding:2px;
		outline: none;		
	}
	
	.login-form input[type=text]:focus,.login-form input[type=password]:focus{			
		border-color:#00EEEE;
		box-shadow:0 0 6px 0 #00AAEE
	}
	
	.login-form button{
		width:260px;
		height:40px;
		margin-top:15px;
		margin-left:60px;
		font-size:18px;
		background-color: transparent;
		border:1px solid #DDDDDD;
		border-radius:10px;
		outline: none;		
	}
	
	.login-form button:hover{
		border:1px solid #557799;
	}
	
	.login-form button:active{
		border:1px solid #FF0000;
	}
	
	.login-form h6{
		color:red;
		text-align:center;
		height:20px;
		line-height:20px;
		margin:0px 0 20px 0;
		padding:0px;
	}

</style>

</head>
<body >

<form id="app" class="login-form" action="" method="post">
	
	<h1>{{title}}</h1>
	<h6></h6>
	<div>
		<label for="u_id">帐号：</label><input v-model="user.u_id"  placeholder="请填写帐号"   type="text"/>		
	</div>
	<div>
		<label for="u_pwd">密码：</label><input v-model="user.u_pwd" placeholder="请填写密码" type="password" />
	</div>
	<div>
		<button  id="submitBn" @click.prevent="login" >登  录</button>
	</div>
	
</form>

<script type="text/javascript" src="../static/js/vue-2.5.16.min.js" ></script>
<script type="text/javascript" src="../static/js/axios.min.js" ></script>
<script src="../static/jqgrid/js/jquery.min.js" type="text/javascript"></script>
<script src="../static/layer/layer.js"></script>

<script type="text/javascript">

new Vue({
	
	el:'#app',
	
	//定义数据
	data:{
		title:'生产过程云信息系统',
		user:{}
	},
	
	//定义方法
	methods:{
		
		login(){
			
			if(!this.user.u_id||this.user.u_id==''){
				
				layer.alert("请输入帐号", {icon: 2}); 
				return;
				
			}
			
			if(!this.user.u_pwd||this.user.u_pwd==''){
				
				layer.alert("请输入密码", {icon: 2}); 
				return;
				
			}
			
			axios
			.post('login', this.user)
			.then(function (response) {
			    let result=response.data;
			    if(result.success){
			    	layer.msg(result.message, {icon: 6,time: 1000 },()=>{
			    		  location.href='../safty/home_to';
			    	}); 
			    }else{
			    	layer.alert(result.message, {icon: 2}); 
			    }
			 })
			.catch(function (error) {
			    console.log(error);
			 });
			
		}
		
	}
	
});

</script>

</body>
</html>